package com.aos.iot.protocol.hll.message;

import cn.hutool.core.util.StrUtil;
import com.aos.iot.protocol.hll.constant.HllProp;
import com.aos.iot.socket.common.message.Message;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class HllMessage extends Message {

    private String head;

    private String version;

    private String encrypt;

    private String length;

    private int lengthInt;

    private String sn;

    private String sign;

    @Override
    public String getMsgId() {
        return StrUtil.equals(this.getVersion(), "01") ?
                StrUtil.format("{}:{}:{}", this.getData().getStr(HllProp.PILE_NO.getValue()), this.getCmd(),
                        this.getData().get(HllProp.PIPE_NO.getValue(), "00")) :
                StrUtil.format("{}:{}", this.getCmd(), this.getSn());
    }

    public String clientId() {
        return getData().get(HllProp.PILE_NO.getValue(), "0000000000");
    }
}
